<script setup lang="ts">
import { ref, watchEffect } from 'vue'

const props = defineProps({
    show: {
        type: Boolean,
        default: false,
    },
    mode: {
        type: String,
        default: 'range',
    },
})
const show = ref(true)
const emit = defineEmits(['change-data', 'change-close'])
console.log(props.show)

//监听父组件传递的值，子组件的值也会跟着改变
watchEffect(() => {
    show.value = props.show
})

const change = (value: any) => {
    emit('change-data', false, value)
    // console.log(value)z
}
const handleclose = () => {
    emit('change-close', false)
}
</script>

<template>
    <u-calendar
        v-model="show"
        :safe-area-inset-bottom="true"
        :change-year="false"
        :mode="props.mode"
        :closeable="true"
        @change="change"
        @close="handleclose"
    ></u-calendar>
</template>

<style lang="scss" scoped></style>
